package com.xuecheng.filesystem.controller;

import com.xuecheng.api.filesystem.FileSystemControllerApi;
import com.xuecheng.filesystem.service.FileSystemService;
import com.xuecheng.framework.domain.filesystem.FileSystem;
import com.xuecheng.framework.domain.filesystem.response.UploadFileResult;
import com.xuecheng.framework.model.response.QueryResponseResult;
import com.xuecheng.framework.model.response.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/filesystem")
public class FileSystemController implements FileSystemControllerApi{

    @Autowired private FileSystemService fileSystemService;


    @Override
    @PostMapping("/upload")
    public UploadFileResult upload(MultipartFile multipartFile, String businesskey, String filetag, String metadata) {
        return fileSystemService.uoload(multipartFile, businesskey,filetag, metadata);
    }

    @Override
    @GetMapping("/findAll/{page}/{size}")
    public QueryResponseResult fandAll(@PathVariable("page")int page,@PathVariable("size") int size, FileSystem fileSystem) {
        return fileSystemService.fandAll(page, size, fileSystem);
    }

    @Override
    @PostMapping("/delete")
    public ResponseResult delete(String fileId) {
        return fileSystemService.delete(fileId);
    }


}
